<!--_meta 作为公共模版分离出去-->
<#include "include/_meta.html">
<!--/meta 作为公共模版分离出去-->

<title>分享爱车-车辆审核</title>
<meta name="keywords" content="汽车租赁">
<meta name="description" content="汽车租赁系统">
</head>
<body>
<article class="page-container">

	<form class="form form-horizontal" id="form-car-edit" >
	<input type="hidden" value="${cars.carid}" id="ispass"/>

	<div class="row cl">
		<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>身份证号：</label>
		<div class="formControls col-xs-8 col-sm-9">
			<input type="text" class="input-text" readonly="readonly" value="${cars.clientuser.idcard!}" placeholder="身份证号" id="idcard" name="idcard">
		</div>
	</div>
	
	<div class="row cl">
		<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>车主姓名：</label>
		<div class="formControls col-xs-8 col-sm-9">
			<input type="text" class="input-text" autocomplete="off" readonly="readonly" value="${cars.clientuser.name}" placeholder="车主姓名" id="name" name="name">
		</div>
	</div>
	<div class="row cl">
		<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>车辆类型</label>
		<div class="formControls col-xs-8 col-sm-9">
			<input type="text" class="input-text" autocomplete="off" readonly="readonly" value="${cars.cartype}" placeholder="车辆类型" id="cartype" name="cartype">
		</div>
	</div>
	
	<div class="row cl">
		<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>车辆品牌：</label>
		<div class="formControls col-xs-8 col-sm-9">
			<input type="text" class="input-text" readonly="readonly" value="${cars.carbrand}" placeholder="车辆品牌" id="carbrand" name="carbrand">
		</div>
	</div>
	<div class="row cl">
		<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>品牌型号：</label>
		<div class="formControls col-xs-8 col-sm-9">
			<input  type="text" class="input-text" readonly="readonly"  value="${cars.carbrandtype}" placeholder="品牌型号" name="carbrandtype" id="carbrandtype">
		</div>
	</div>
	<div class="row cl">
		<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>申请日期：</label>
		<div class="formControls col-xs-8 col-sm-9">
			<input type="text" class="input-text" readonly="readonly" value="${cars.carOrderTime}" placeholder="购买日期" name="buydate" id="buydate">
		      
		</div>
	</div>
	
	<hr/>
	
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>是事故车：</label>
		<div class="formControls col-xs-8 col-sm-9"> <span class="select-box" style="width:150px;">
			<select class="select" id="hadaccident" name="hadaccident" size="1">
			    <option value="-1">--请选择--</option>
				<option value="0">否</option>
				<option value="1">是</option>
			</select>
			</span></div>
	</div>
		<div class="row cl">
		<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>是否大修：</label>
        <div class="formControls col-xs-8 col-sm-9"> <span class="select-box" style="width:150px;">
            <select class="select" id="isbadrepair" name="isbadrepair" size="1">
                 <option value="-1">--请选择--</option>
                <option value="0">否</option>
                <option value="1">是</option>
            </select>
            </span>
		</div>
	</div>
		<div class="row cl">
		<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>现有违章：</label>
		<div class="formControls col-xs-8 col-sm-9">
			<input type="text" class="input-text" value="" placeholder="现有违章" name="hadillegal" id="hadillegal">
		</div>
	</div>
		<div class="row cl">
		<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>投保单位：</label>
		<div class="formControls col-xs-8 col-sm-9">
			<input type="text" class="input-text" value="" placeholder="投保单位" name="insurer" id="insurer">
		</div>
	</div>
	
		<div class="row cl">
		<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>年检到期：</label>
		<div class="formControls col-xs-8 col-sm-9">	
		<input type="text" onfocus="WdatePicker()" id="yearcheck" class="input-text Wdate" style="width:120px;">
		</div>
	</div>
		<div class="row cl">
		<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>下次保养时间：</label>
		<div class="formControls col-xs-8 col-sm-9">
			<input type="text" onfocus="WdatePicker()" id="maintaintime" class="input-text Wdate" style="width:120px;">
		</div>
	</div>
		<div class="row cl">
	   <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>安全系数：</label>
        <div class="formControls col-xs-8 col-sm-9"> <span class="select-box" style="width:150px;">
            <select class="select" id="safelevel" name="safelevel" >
                 <option value="-1">--请选择--</option>
                <option value="0">低</option>
                <option value="1">中</option>
                <option value="2">高</option>
            </select>
            </span>
        </div>
	</div>
		<div class="row cl">
		<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>车辆估值：</label>
		<div class="formControls col-xs-8 col-sm-9">
			<input type="text" class="input-text" value="" placeholder="车辆估值" name="carprice" id="carprice">
		</div>
	</div>
		<div class="row cl">
		<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>车辆里程：</label>
		<div class="formControls col-xs-8 col-sm-9">
			<input type="text" class="input-text" value="" placeholder="车辆里程" name="totalmile" id="totalmile">
		</div>
	</div>
	   <div class="row cl">
        <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>伪造里程：</label>
        <div class="formControls col-xs-8 col-sm-9">
            <input type="text" class="input-text" value="" placeholder="伪造里程" name="isfakemile" id="isfakemile">
        </div>
    </div>
		<div class="row cl">
		<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>下次保养里程：</label>
		<div class="formControls col-xs-8 col-sm-9">
			<input type="text" class="input-text" value="" placeholder="下次保养里程" name="maintainmile" id="maintainmile">
		</div>
	</div>
    <div class="row cl">
        <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>评估人员：</label>
        <div class="formControls col-xs-8 col-sm-9">
            <input type="text" class="input-text" value="" placeholder="评估人员" name="evaluater" id="evaluater">
        </div>
</div>
<br/>
	<div align="center" style="float:left height:60px">

			<input id="checkpass" class="btn btn-primary radius" type="button" value="&nbsp;&nbsp;审核通过&nbsp;&nbsp;"/>

			<input id="checknopass" class="btn btn-primary radius" type="button" value="&nbsp;&nbsp;审核不通过&nbsp;&nbsp;" />
	</div>
	</form>
</article>

<!--_footer 作为公共模版分离出去--> 
<#include "include/_footer.html">
<!--/_footer /作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript">

	 //向服务器提交审核车辆是否通过
	 var updateUser = function (ispass) {
		 $.ajax({
			 type: "POST",
			 dataType: "json",
			 url: "/checkcars/upEdit",
			 data: {
				 carid: $("#ispass").val(),
				 hadaccident: $("#hadaccident").val(),
				 isbadrepair: $("#isbadrepair").val(),
				 hadillegal: $("#hadillegal").val(),
				 insurer: $("#insurer").val(),
				 yearcheck: $("#yearcheck").val(),
				 maintaintime: $("#maintaintime").val(),
				 safelevel: $("#safelevel").val(),
				 carprice: $("#carprice").val(),
				 totalmile: $("#totalmile").val(),
				 isfakemile: $("#isfakemile").val(),
				 maintainmile: $("#maintainmile").val(),
				 evaluater: $("#evaluater").val(),
				 carstate:ispass
			 },
			 success: function (msg) {
				 $("#checknopass").click();
			 }
		 });
	 }


	//校验字段是否正确
	function check(){
		/*关键在这儿，返回的是一个validate对象，这个对象有一个form方法，返回的是是否通过验证*/
		if(hadaccident.value==(-1)){
			alert("请选择是否大修");
		}else if(isbadrepair.value==(-1)){
			alert("请选择是否是事故车");

		}else if(safelevel.value==(-1)){
			alert("请选择是否是事故车");

		}
		return $("#form-car-edit").validate({
					rules:{
						totalmile:{
							required:true
						},
						hadillegal:{
							required:true
						},
						  insurer:{
							required:true
						},
						  isfakemile:{
							required:true
						},
						  safelevel:{
							required:true
						},
						  carprice:{
							required:true
						},
						  evaluater:{
							required:true
						},
						  maintainmile:{
							required:true
						}

					},
					messages:{
						totalmile:{
							required:"名称不能为空"
						} ,
					 hadillegal:{
							required:"现有违章不能为空"
						},
						  insurer:{
							required:"投保单位不能为空"
						},
						  isfakemile:{
							required:"伪造里程不能为空"
						} ,
						  safelevel:{
							required:"安全系数不能为空"
						},
						  carprice:{
							required:"车辆估值不能为空"
						},

						  evaluater:{
							required:"评估人员不能为空"
						},
						  maintainmile:{
							required:"下次保养里程不能为空"
						}
					}
				});
	}


$(function(){

	 //给审核通过按钮初始化事件
	 $("#checkpass").click(function(){
		  if(!check().form()) return;
		 updateUser(5);
	 });

	 //给审核不通过按钮初始化事件
	 $("#checknopass").click(function(){
		 var index = parent.layer.getFrameIndex(window.name);
		 parent.get;
		 parent.layer.close(index);

	 });

});
</script>
<!--/请在上方写此页面业务相关的脚本-->
</body>
</html>